#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <windows.h>
#include <io.h>
#include "deletefile.h"
int deleteFile(char* filestr) {
    FILE* file = fopen(filestr,"r");
    if (file == NULL) {
        return -1;
    }

    HANDLE fileHandle = (HANDLE)_get_osfhandle(_fileno(file));
    if (fileHandle == INVALID_HANDLE_VALUE) {
        return -1;
    }

    char filename[MAX_PATH];
    if (GetFinalPathNameByHandleA(fileHandle, filename, MAX_PATH, VOLUME_NAME_DOS)) {
        if (remove(filename) == 0) {
            return 0;
        }
        else {
        }
    }
    else {
    }

    return -1;
}